package com.boot.persistence.validate.validator;

import cn.hutool.core.bean.BeanUtil;
import com.boot.persistence.model.BaseModel;
import com.boot.persistence.validate.annotation.Insert;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.io.Serializable;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 删除操作的验证逻辑
 * @date 2020/4/8 16:10
 **/

public class InsertValidator implements ConstraintValidator<Insert, BaseModel<? extends Serializable>> {

    @Override
    public boolean isValid(BaseModel<? extends Serializable> model, ConstraintValidatorContext context) {
        return !BeanUtil.isEmpty(model, "id", "createTime", "updateTime",
                "createUser", "updateUser", "deleted", "readOnly", "serialVersionUID");
    }
}
